var gulp = require('gulp')
    , uglify = require('gulp-uglify')
    , concat = require('gulp-concat')
    , minifyCss = require('gulp-minify-css');

var taskPath = require('./path');

module.exports = {
    // 压缩合并类库js文件
    copyResLibs: function () {
        return gulp.src(taskPath.RES_LIBS.src)
            .pipe(concat(taskPath.RES_LIBS.prod))
            // .pipe(gulpif(options.env === 'production', uglify())) // 仅在生产环境时候进行压缩
            .pipe(uglify())
            .pipe(gulp.dest(taskPath.DIR_BUILD + '/libs'));
    },
    // 复制并合并压缩css文件
    copyResCss: function () {
        return gulp.src(taskPath.RES_CSS.src)
            .pipe(concat(taskPath.RES_CSS.prod))
            .pipe(minifyCss())
            .pipe(gulp.dest(taskPath.DIR_BUILD + '/libs'));
    },
    // 复制并合并ApiConfig
    copyResConfig: function () {
        return gulp.src(taskPath.RES_CONFIG.src)
            .pipe(concat(taskPath.RES_CONFIG.prod))
            .pipe(uglify())
            .pipe(gulp.dest(taskPath.DIR_BUILD + '/libs'));
    }
};
